<html>
<head><meta charset="utf-8"><title>MCP for implicit mod? · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html">MCP for implicit mod?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204465714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204465714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204465714">(Jul 20 2020 at 19:32)</a>:</h4>
<p>In response to an <a href="http://www.sheshbabu.com/posts/rust-module-system/">article that came out recently explaining the module system</a>, there's been some renewed interest in implicit <code>mod</code>, for the common case where modules have the same structure as the filesystem. Now that we're not making other changes at the same time, I think it might be feasible to make such a change for a future edition. I would be interested in seeing that happen, as long as there's still a way to ask for explicit-modules-only for more complex module organizational cases.</p>



<a name="204465744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204465744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204465744">(Jul 20 2020 at 19:32)</a>:</h4>
<p>I think it would make sense to handle that through the MCP process, and charter a project group for it.</p>



<a name="204465827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204465827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204465827">(Jul 20 2020 at 19:33)</a>:</h4>
<p>I'm wondering if there would be objections at the conceptual level (in which case those need addressing before chartering a group), or if objections would be to the details (in which case the project group process could resolve them).</p>



<a name="204466551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204466551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204466551">(Jul 20 2020 at 19:39)</a>:</h4>
<p>I remember that when we were doing the 2018 module system, we dropped implicit <code>mod</code> not because we didn't want it to happen, but because we felt it would be doing too much at once and would prevent us from getting the rest through.</p>



<a name="204466602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204466602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204466602">(Jul 20 2020 at 19:40)</a>:</h4>
<p>I'm hoping that it could be smoother as a separate step.</p>



<a name="204467321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467321">(Jul 20 2020 at 19:46)</a>:</h4>
<p>When you say "conceptual level," can you elaborate what you mean by that? Opposition to the idea itself rather than a concrete implementation?</p>



<a name="204467542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467542">(Jul 20 2020 at 19:48)</a>:</h4>
<p>Right, exactly.</p>



<a name="204467564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467564">(Jul 20 2020 at 19:48)</a>:</h4>
<p>Objections on the conceptual level would be if someone doesn't <em>ever</em> want modules to depend on the filesystem.</p>



<a name="204467589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467589">(Jul 20 2020 at 19:48)</a>:</h4>
<p>I personally have some concerns about this, especially because I am not completely sure about the target audience which are probably newish users here. I am fairly concerned that there is already so much code and tutorials out there which reference the current state of the module system that this change would end up causing more confusion instead</p>



<a name="204467668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467668">(Jul 20 2020 at 19:49)</a>:</h4>
<p>Objections to the details might be "can we make the compiler do that efficiently, including for incremental compilation", or "how easily can existing projects avoid this if they want to have .rs files laying around that shouldn't be used".</p>



<a name="204467768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467768">(Jul 20 2020 at 19:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F/near/204467589">said</a>:</p>
<blockquote>
<p>I personally have some concerns about this, especially because I am not completely sure about the target audience which are probably newish users here. I am fairly concerned that there is already so much code and tutorials out there which reference the current state of the module system that this change would end up causing more confusion instead</p>
</blockquote>
<p>The goal would definitely be to make it more usable for new users. I'm <em>hoping</em> that this would be like the 2018 edition, where almost all code Just Works unless there's ambiguity.</p>



<a name="204467819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467819">(Jul 20 2020 at 19:50)</a>:</h4>
<p>So I think that we would have to enable this for a whole crate at once</p>



<a name="204467828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467828">(Jul 20 2020 at 19:51)</a>:</h4>
<p>Right.</p>



<a name="204467863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467863">(Jul 20 2020 at 19:51)</a>:</h4>
<p>aah, nm I was concerned with conditional modules</p>



<a name="204467893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467893">(Jul 20 2020 at 19:51)</a>:</h4>
<p>and that they would require an update of the complete crate when introduced</p>



<a name="204467967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467967">(Jul 20 2020 at 19:52)</a>:</h4>
<p>but we can do the following inside of the module instead, so this should be fine</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![cfg(windows)]</span><span class="w"></span>
</code></pre></div>



<a name="204467973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204467973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204467973">(Jul 20 2020 at 19:52)</a>:</h4>
<p>Ah, that's another good example of something that will depend on the details.</p>



<a name="204468004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468004">(Jul 20 2020 at 19:52)</a>:</h4>
<p>1) Can we do that as efficiently, or would there be a performance hit from doing so?</p>



<a name="204468063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468063">(Jul 20 2020 at 19:53)</a>:</h4>
<p>(One interesting side-effect, is that if we can get rid of <code>mod foo;</code> completely, it side-steps the question of what proc macros should do when annotating <code>mod foo;</code>)</p>



<a name="204468079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468079">(Jul 20 2020 at 19:53)</a>:</h4>
<p>2) <em>Could</em> we add a mechanism for conditional use of implicit modules, without having to move the conditionals inside the module?</p>



<a name="204468205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468205">(Jul 20 2020 at 19:54)</a>:</h4>
<p>Another consideration is rust-analyzer- a) how would implicit <code>mod</code> impact its ability to work lazily/incrementally? and b) from the other side, is there anything it could do that would solve the usability problem without changing the language?</p>



<a name="204468259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468259">(Jul 20 2020 at 19:54)</a>:</h4>
<p>It might, for instance, be possible to have something like <code>#[cfg(...)] pub use windows::foo as foo</code> and <code>#[cfg(...)] pub use linux::foo as foo</code> and have that work naturally.</p>



<a name="204468561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468561">(Jul 20 2020 at 19:57)</a>:</h4>
<p>there are definitely various details</p>



<a name="204468592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468592">(Jul 20 2020 at 19:57)</a>:</h4>
<p>for example, right now <code>#[cfg(foo)] mod bar</code> means that <code>bar.rs</code> is never even <em>parsed</em></p>



<a name="204468601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468601">(Jul 20 2020 at 19:57)</a>:</h4>
<p>and hence it may contain unstable or invalid syntax</p>



<a name="204468716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468716">(Jul 20 2020 at 19:58)</a>:</h4>
<p>Right. That seems like a critical requirement to me.</p>



<a name="204468728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468728">(Jul 20 2020 at 19:58)</a>:</h4>
<p>I'm in favor of the general idea but I do think there's a lot of details to work out; it's probably not where I personally would choose to invest my energy</p>



<a name="204468763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468763">(Jul 20 2020 at 19:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F/near/204468592">said</a>:</p>
<blockquote>
<p>for example, right now <code>#[cfg(foo)] mod bar</code> means that <code>bar.rs</code> is never even <em>parsed</em></p>
</blockquote>
<p>to be clear, we've discussed before that this doesn't meet many users' expectations</p>



<a name="204468774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468774">(Jul 20 2020 at 19:59)</a>:</h4>
<p>and that it would be better if we could do that at finer granularity</p>



<a name="204468789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468789">(Jul 20 2020 at 19:59)</a>:</h4>
<p>e.g., being able to tag a function that used unstable syntax within</p>



<a name="204468801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468801">(Jul 20 2020 at 19:59)</a>:</h4>
<p>(but there are impl challenges to be overcome)</p>



<a name="204468805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468805">(Jul 20 2020 at 19:59)</a>:</h4>
<p>I find myself wondering if we <em>could</em> guarantee that if there's a module-level <code>#![cfg(...)]</code> that isn't matched, Rust will never parse the rest of the file.</p>



<a name="204468819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468819">(Jul 20 2020 at 19:59)</a>:</h4>
<p>(Leaving aside the question of whether that's what we want.)</p>



<a name="204468830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468830">(Jul 20 2020 at 19:59)</a>:</h4>
<p>Probably</p>



<a name="204468847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468847">(Jul 20 2020 at 20:00)</a>:</h4>
<p>One thing I will say: I don't believe this feature is "just" for newbie users</p>



<a name="204468912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468912">(Jul 20 2020 at 20:00)</a>:</h4>
<p>I can definitely attest to being "not a noob" and still confused/surprised by our behavior</p>



<a name="204468937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468937">(Jul 20 2020 at 20:00)</a>:</h4>
<p>I've certainly wanted it; I <em>regularly</em> forget to write <code>mod foo;</code> after adding <code>foo.rs</code>.</p>



<a name="204468938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468938">(Jul 20 2020 at 20:00)</a>:</h4>
<p>Sometimes it's just "oh, I have to add a <code>mod</code>", but often it's like this:</p>



<a name="204468949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468949">(Jul 20 2020 at 20:00)</a>:</h4>
<p>I write a <code>test.rs</code> file with tests</p>



<a name="204468954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468954">(Jul 20 2020 at 20:00)</a>:</h4>
<p>I run <code>cargo test</code>, everything seems green</p>



<a name="204468961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468961">(Jul 20 2020 at 20:00)</a>:</h4>
<p>I don't realize the tests never even <em>ran</em> :)</p>



<a name="204468977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204468977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204468977">(Jul 20 2020 at 20:00)</a>:</h4>
<p>(or <em>compiled</em>) :)</p>



<a name="204469046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469046">(Jul 20 2020 at 20:01)</a>:</h4>
<p>Yup, that seems like a good use case for motivation.</p>



<a name="204469177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469177">(Jul 20 2020 at 20:02)</a>:</h4>
<p>We could also have rules like "we don't look at module files whose basenames aren't valid Rust module names", which would address things like <code>.something.rs</code> or <code>foo.MERGED.rs</code> or <code>foo.OURS.rs</code>.</p>



<a name="204469215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469215">(Jul 20 2020 at 20:03)</a>:</h4>
<p>I would personally suspect that we could get 90% of the benefit with a lint that says "hey you have an unused file, go add a mod foo for it"</p>



<a name="204469273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469273">(Jul 20 2020 at 20:03)</a>:</h4>
<blockquote>
<p>I don't believe this feature is "just" for newbie users</p>
</blockquote>
<p>My concern is not that this feature only helps newbies, I am afraid that this feature may end up hurting newbies (regardless of if it helps more advanced users)</p>



<a name="204469332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469332">(Jul 20 2020 at 20:04)</a>:</h4>
<p>(see e.g. <a href="https://github.com/rust-lang/rust/issues/28711">https://github.com/rust-lang/rust/issues/28711</a>)</p>



<a name="204469712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469712">(Jul 20 2020 at 20:07)</a>:</h4>
<p>There were widespread and strongly felt objections to this concept during the ergonomics initiative and it would be very controversial to pursue it. I also think we cannot make major changes to the module system any time in the near future, because we made such a huge overhaul in 2018. I would have prefered if Rust had not required explicit mod statements, but I think pursuing this now would be a big mistake.</p>



<a name="204469889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204469889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204469889">(Jul 20 2020 at 20:09)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> Do you feel similarly about the more limited "just linting" proposal?</p>



<a name="204470005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204470005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204470005">(Jul 20 2020 at 20:10)</a>:</h4>
<p>No I think linting would not be very controversial</p>



<a name="204473063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473063">(Jul 20 2020 at 20:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F/near/204468601">said</a>:</p>
<blockquote>
<p>and hence it may contain unstable or invalid syntax</p>
</blockquote>
<p>This is a trick that I use when targeting my crate to support Rust version $OLD but with some opt-in code for version $NEW, so I'd be really sad to see it go.</p>



<a name="204473144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473144">(Jul 20 2020 at 20:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F/near/204469215">said</a>:</p>
<blockquote>
<p>I would personally suspect that we could get 90% of the benefit with a lint that says "hey you have an unused file, go add a mod foo for it"</p>
</blockquote>
<p>I like the lint idea, but how would you turn it off for a specific file?</p>



<a name="204473479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473479">(Jul 20 2020 at 20:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> easiest option is something like <code>#[cfg(false)] mod the_orphan_file;</code> - my guess is the primary challenge with any such lint is going to be the fundamentally "shared namespace" problem of Cargo projects with src/lib.rs, src/main.rs, src/foo.rs -- when compiling <a href="http://lib.rs">lib.rs</a> or <a href="http://main.rs">main.rs</a> you don't know if <a href="http://foo.rs">foo.rs</a> is 'intentionally' orphan.</p>
<p>I think that challenge is pervasive in any sort of project like this, in some sense.</p>



<a name="204473528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473528">(Jul 20 2020 at 20:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256759">boats</span> <a href="#narrow/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F/near/204469712">said</a>:</p>
<blockquote>
<p>There were widespread and strongly felt objections to this concept during the ergonomics initiative and it would be very controversial to pursue it. I also think we cannot make major changes to the module system any time in the near future, because we made such a huge overhaul in 2018. I would have prefered if Rust had not required explicit mod statements, but I think pursuing this now would be a big mistake.</p>
</blockquote>
<p>I remember there being two major families of objections at the time.</p>
<p>One set were the overall objections to an overhaul of the module system that would require a lot of migration work in every crate; we ended up with a module system that didn't require nearly as much migration because it was <em>mostly</em> backwards-compatible, and if we were to change something again in the future, I'd similarly want something mostly backwards-compatible.</p>
<p>The other set were the use cases that specifically wanted to be able to have <code>.rs</code> files in a directory without Rust looking at those. I feel like those were treated as complete showstoppers, and I'm wondering to what degree those problems are actually fixable in a backwards-compatible way (e.g. "if you have mod statements default to explicit-mod-statements-required", or some other system that ensures current crates mostly Just Work while new crates could avoid explicit mod, the same way <code>extern crate</code> still works).</p>



<a name="204473601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473601">(Jul 20 2020 at 20:42)</a>:</h4>
<p>All that said, I can completely understand if it feels like we shouldn't spend energy on this right now.</p>



<a name="204473656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473656">(Jul 20 2020 at 20:43)</a>:</h4>
<p>But I'd love to see us eventually figure out if there <em>could</em> be a viable path to a solution.</p>



<a name="204473717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473717">(Jul 20 2020 at 20:44)</a>:</h4>
<p>In any case, a lint for "you forgot to add a mod statement" seems like a good start.</p>



<a name="204473771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473771">(Jul 20 2020 at 20:44)</a>:</h4>
<p>And the work needed to one day make that a deny-by-default lint would be much of the same work of figuring out how to address use cases.</p>



<a name="204473826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204473826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204473826">(Jul 20 2020 at 20:45)</a>:</h4>
<p>I'd be quite happy to see a change proposal for such a lint.</p>



<a name="204474495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204474495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204474495">(Jul 20 2020 at 20:51)</a>:</h4>
<p>Another lint in this area could be for <code>my_module::my_module</code>, where people wrap their entire file <code>foo.rs</code> with <code>mod foo { /* ... */ }</code>. It's not _wrong_, but not usually what you want.</p>



<a name="204474755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204474755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204474755">(Jul 20 2020 at 20:54)</a>:</h4>
<p>I do tend to agree with <span class="user-mention" data-user-id="256759">@boats</span> that we "took our shot" at modules.</p>



<a name="204474834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204474834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204474834">(Jul 20 2020 at 20:55)</a>:</h4>
<p>Yea, for me this is the big issue. I think some users will take it as a reversal to re-open this question for the 2021 edition &amp; I think in general it will contribute majorly to a perception problem of being churny</p>



<a name="204475092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204475092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204475092">(Jul 20 2020 at 20:58)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> I would absolutely support just saying "we're not going to do this for 2021", just to avoid the perception of churn, and giving it some consideration for 2024. A lint might potentially pave the way towards doing so.</p>



<a name="204475833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204475833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204475833">(Jul 20 2020 at 21:04)</a>:</h4>
<p>+1 for the lint, -1 for implicit modules. Something I do a lot for testing rustdoc changes is making a temporary rust file in the current directory so I can run rustdoc on it. With this change I'd have to clean that up before even running x.py check (or I'd get the warnings and errors from that file).</p>



<a name="204476605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204476605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204476605">(Jul 20 2020 at 21:10)</a>:</h4>
<p>When you say "in the current directory", do you mean in some subdirectory of the repo, or at the top level of the repo?</p>



<a name="204477227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204477227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204477227">(Jul 20 2020 at 21:15)</a>:</h4>
<p>various places, but usually a subdirectory</p>



<a name="204477316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204477316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204477316">(Jul 20 2020 at 21:16)</a>:</h4>
<p>I have an alias <code>xpy</code> that runs x.py from the top-level directory, which lets me cd around without having to use awful things like <code>../../x.py</code></p>



<a name="204477503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204477503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204477503">(Jul 20 2020 at 21:18)</a>:</h4>
<p>and outside of that I'd be worried about compilation times if you have a vendored dependency you forgot to get rid of or something - <a href="http://docs.rs">docs.rs</a> ran into something similar with <a href="https://github.com/Gilnaa/globwalk/issues/29">https://github.com/Gilnaa/globwalk/issues/29</a></p>



<a name="204477855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204477855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204477855">(Jul 20 2020 at 21:21)</a>:</h4>
<p>something that might work better is to only load the module if you refer to it somewhere else in the code</p>



<a name="204477897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204477897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204477897">(Jul 20 2020 at 21:21)</a>:</h4>
<p>so if you have <code>use crate::x;</code> but there's no <code>mod x;</code> declaration, rustc would automatically look for <code>x.rs</code>. I'd be ok with that.</p>



<a name="204477966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204477966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204477966">(Jul 20 2020 at 21:22)</a>:</h4>
<p>I guess that wouldn't help with the 'unit tests being forgotten' use case though :/</p>



<a name="204478458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204478458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204478458">(Jul 20 2020 at 21:27)</a>:</h4>
<p>I remember thinking that the lint was a good starting point the last time we talked about this</p>



<a name="204478464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204478464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204478464">(Jul 20 2020 at 21:27)</a>:</h4>
<p>would force us to solve all the usual issues</p>



<a name="204478526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204478526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204478526">(Jul 20 2020 at 21:28)</a>:</h4>
<p>but takes away the controversial part of it, let's us focus more on the implementation details</p>



<a name="204490883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204490883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204490883">(Jul 20 2020 at 22:20)</a>:</h4>
<p>As long as inline modules never go away I'll be fine.</p>



<a name="204519313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204519313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Peter Rabbit <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204519313">(Jul 21 2020 at 07:40)</a>:</h4>
<p>I think the lint for unused source files is a great idea which we should definitely do, unlike implicit modules.</p>



<a name="204540551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204540551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204540551">(Jul 21 2020 at 12:27)</a>:</h4>
<p>I think implementing a lint for unused source files in a Cargo-based project will have the same problems as detecting unused dependencies.  I think it will be even worse, since modules sometimes use <code>#[cfg]</code>, in which case rustc won't even see that there are potentially used modules.  est31 has been doing some work on the unused dependencies front, but it is quite complex, and doesn't fit with rustc's lint system, which means there would need to be separate controls for allow/deny, which is quite unfortunate.</p>



<a name="204542818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/204542818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#204542818">(Jul 21 2020 at 12:51)</a>:</h4>
<p>yeah that's my thought as well, but I think the lint is the right first step, if we do it. But I think we don't have the resources <em>now</em> to dedicate to this personally.</p>



<a name="208433978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/208433978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#208433978">(Aug 29 2020 at 13:27)</a>:</h4>
<p>As a late reply to this, I just wanted automatic / implicit modules.</p>
<p>I want to reorganize a bunch of integration tests from <code>/tests/foo-{a,b}.rs</code> to <code>/tests/foo/{a,b}.rs</code>. That's not supported by Cargo's test discovery, so I need to now have <code>mod a</code> and <code>mod b</code>. If I forget that line, then my test file won't be run. </p>
<p>I wouldn't usually want this, however, so opting in with something something like <code>mod *</code> would be fine.</p>



<a name="208448841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/208448841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matt rice <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#208448841">(Aug 29 2020 at 19:03)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F/near/204474495">said</a>:</p>
<blockquote>
<p>Another lint in this area could be for <code>my_module::my_module</code>, where people wrap their entire file <code>foo.rs</code> with <code>mod foo { /* ... */ }</code>. It's not _wrong_, but not usually what you want.</p>
</blockquote>
<p>Another late reply, but I actually find myself doing this a lot due to generally starting out writing <code>mod foo { /* ... */ }</code> in <em>lib.rs</em> then only eventually perhaps moving it to <em>foo.rs</em> and adding <code>pub use foo::*</code> at the top of <em>foo.rs</em>.  At least that is the only way i've found to keep everything rustfmt and compiling while allowing git aware of the code movement.</p>



<a name="208492099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/208492099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#208492099">(Aug 30 2020 at 16:20)</a>:</h4>
<p>There's <a href="https://github.com/dtolnay/automod">this crate</a> by the way.</p>



<a name="208492224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/208492224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#208492224">(Aug 30 2020 at 16:23)</a>:</h4>
<p>I would rather have this as a crate then part of the language I think</p>



<a name="208683039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/208683039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#208683039">(Sep 01 2020 at 13:00)</a>:</h4>
<blockquote>
<p>Suppose that we would like to keep a directory of regression tests for individual numbered issues:</p>
</blockquote>
<p>LOL, what a nice example use case :-)</p>



<a name="208683242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/MCP%20for%20implicit%20mod%3F/near/208683242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/MCP.20for.20implicit.20mod.3F.html#208683242">(Sep 01 2020 at 13:01)</a>:</h4>
<p>I really should just get into the habit of assuming that dtolnay has fixed most of my problems before I have them.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>